/* WARNING! An automated open bar robotic bartender can be dangerouse to your health. if you feel too drunk and drinking is negatively affecting you or others delete this code and end the robot*/ #include // the best library ever, command servos to go to angles ( up to 8 asynch)(<-- na ahh im doing like 13 yoooo) at desired speed.Download from github for latst version #include // library for ultrasonic sensor to function/*#include */ /*Servo_9;// Lower bottle clamper servo*/ VarSpeedServo Servo_1; VarSpeedServo Servo_2; VarSpeedServo Servo_3; VarSpeedServo Servo_4; VarSpeedServo Servo_5; VarSpeedServo Servo_6; VarSpeedServo Servo_7; VarSpeedServo Servo_8; VarSpeedServo Servo_9; VarSpeedServo Servo_10; VarSpeedServo Servo_11; /* Set up Ultrasonic sensor blow */ #define TRIG_PIN 12 #define ECHO_PIN 11 SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN); long a; /*--------------------------*/ /*set up 6 angle variables for futur upgradability & advancd logic*/ int angle_1 = 90; int angle_2 = 90; int angle_3 = 90; int angle_4 = 90; int angle_5 = 90; int angle_6 = 90; int defaultdelay = 2000;// common delay to adjust transition time,at higher level9turns out most actions need customn delay anyways so not too useful in retrospect0 void setup() { Serial.begin(9600); // Ultrasonic sensor baud rate Servo_1.attach (2, 0, 360); // attach the signal pin of servo to pin2 of arduino Servo_2.attach (3, 0, 360); // attach the signal pin of servo to pin3 of arduino Servo_3.attach (4, 0, 360); // attach the signal pin of servo to pin4 of arduino Servo_4.attach (5, 0, 360); // attach the signal pin of servo to pin5 of arduino Servo_5.attach (6, 0, 360); // attach the signal pin of servo to pin6 of arduino Servo_6.attach (7, 0, 360); // attach the signal pin of servo to pin7 of arduino Servo_7.attach (8, 0, 360); // attach the signal pin of servo to pin8 of arduino Lower botttle Clamp Servo_8.attach (9, 0, 360); // attach the signal pin of servo to pin9 of arduino Rocker Arm Assmebly Servo_9.attach (10, 0, 360); // attach the signal pin of servo to pin10 of arduino Bottle cap spinner Servo_10.attach (12, 0, 360); // attach the signal pin of servo to pin12 of arduino bottle cap pincher Servo_11.attach (13, 0, 360); // attach the signal pin of servo to pin13 of arduino bottle slide bouncer gate } void loop() { /*below sends out ultrasonic radings to seriel printout to view and debug only. used to ID if human cup is placed in the slot designed to indiate time for newfill or re-fill, aka human wants to get hammered*/ a=sr04.Distance(); Serial.print(a); Serial.println("cm"); delay(1500); //below is basic logic to ID if human has desired intent for newfill or refill of drink //------------------------------------------------------------------------------------------------------------------------------- if ((a <= 8.5) && (a >=0.5)){ //set up all servo ready fro operation Servo_1.slowmove (90, 20);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (180, 30);// twist rist to properly aling with bottle Servo_3.slowmove (55, 10); // raise end effecotr to clear bottles over arm swing start up action; Servo_3.wait(); // wait for servo 3 to finish Servo_4.slowmove (30, 10); Servo_4.wait(); // wait for servo to finish Servo_5.slowmove (180, 10); Servo_5.wait(); // wait for servo5 to finish Servo_6.slowmove (180, 10);//slowly swing arm to intemrideay stagin area Servo_6.wait(); // wait for servo 6 to finish Servo_7.slowmove (170, 5); //move lower bottle clamp holder out of way to allow bottle to lide into spot once released Servo_8.slowmove (360, 5); //move rocker arm out of way to letbottle slide down wihtout hitting anything once its released Servo_9.slowmove (180,10);// attmepts to put spin 360 servo in stationay mode, may need loght tweaaking Servo_10.slowmove (140, 3); //open cap pinch fingers Servo_11.slowmove (180, 30);//reset bottle bouncer for next slide down //------------------------------------- Servo_11.slowmove (5, 30);//let bottle slide down ? );//let one bottle down bottle slide Servo_11.wait(); // wait for servo 8 to finish Servo_11.slowmove (180, 30);//reset bottle bouncer for next slide down delay(600); Servo_7.slowmove (20, 70); //tighten down to help alingbottle if landed sloppy Servo_7.wait(); // wait for servo 7 to finsih cmalpingbottle Servo_10.slowmove (120, 240); //open cap pinch fingers delay(5); Servo_7.slowmove (100, 70); //loosen hold on bottle with lower bottle clamp holder to mitigate with aligment squish issues bottle concentricity Servo_7.wait(); // wait for servo 7 to finsih clamping move Servo_8.slowmove (0, 80);// push rocker amr forward to land ontop of bottle Servo_8.wait(); // wait for servo 8 to finish delay(300); Servo_7.slowmove (20, 70); //tighten down on bottle with lower bottle clamp holder so that when you twist the cap off it wont spin in place Servo_7.wait(); // wait for servo 7 to finsih clamping move Servo_10.slowmove (180, 240); //Pinch Servo_10.wait(); // wait for servo 10 to finish delay(350); Servo_9.slowmove (30,15); //spin pincher assmbely to unscrew bottle cap part 1 Servo_9.wait(); // wait for servo 9 to finish spiniing delay(30); Servo_10.slowmove (120, 150); //un Pinch, Servo_10.wait(); // wait for servo 10 to finish unpinching Servo_8.slowmove (60, 100);// pull back rocker arm back to get to ready to rewind Servo_8.wait(); // wait for servo 8 to finish Servo_9.slowmove (180,100); //unspin pincher assmbely to untangel servo cable Servo_9.wait(); // wait for servo 9 to finish delay(100); Servo_8.slowmove (0, 100);// push rocker amr forward to land ontop of bottle Servo_8.wait(); // wait for servo 8 to finish Servo_10.slowmove (180, 190); //Pinch Servo_10.wait(); // wait for servo 10 to finish Servo_9.slowmove (0,40); //spin pincher assmbely to unscrew bottle cap part 2 Servo_9.wait(); // wait for servo 9 to finish spiniing Servo_10.slowmove (120, 190); //relax Pinch a bit delay (10); Servo_8.slowmove (60, 100);// pull back rocker arm back to get to ready to rewind Servo_8.wait(); // wait for servo 8 to finish Servo_9.slowmove (180,100); //unspin pincher assmbely to untangel servo cable Servo_9.wait(); // wait for servo 9 to finish delay(100); Servo_8.slowmove (0, 100);// push rocker amr forward to land ontop of bottle Servo_8.wait(); // wait for servo 8 to finish Servo_10.slowmove (180, 190); //Pinch Servo_10.wait(); // wait for servo 10 to finish Servo_9.slowmove (0,40); //spin pincher assmbely to unscrew bottle cap part 3 Servo_9.wait(); // wait for servo 9 to finish spiniing Servo_7.slowmove (180, 5); //let go of bottle with lower clamp holder delay(50); Servo_8.slowmove (180, 70);// pull back rocker arm back to prepare for cap drop Servo_8.wait(); // wait for servo 8 to finish Servo_10.slowmove (180, 250); //un Pinch, drop bottle cap somehwhere delay(50); Servo_10.slowmove (100, 100); //relax Pinch a bit delay (50); Servo_10.slowmove (90, 250); //un Pinch, drop bottle cap somehwhere delay(50); Servo_10.slowmove (120, 100); //relax Pinch a bit Servo_10.slowmove (90, 250); //un Pinch, drop bottle cap somehwhere delay(50); Servo_10.slowmove (120, 100); //relax Pinch a bit Servo_9.slowmove (180,25); //unspin pincher assmbely to untangel servo cable delay(1000); //----------------------------------------------------------------------------------------------------------------- Servo_2.slowmove (180, 5); Servo_6.slowmove (41, 40);//slowly swing arm to general bottle grab location Servo_6.wait(); // wait for servo 6 to finish Servo_3.slowmove (125, 25); // raise end effecotr to clear bottles over arm swing start up action Servo_3.wait(); // wait for servo to finish Servo_4.slowmove (30, 20); Servo_4.wait(); // wait for servo 4 to finish Servo_3.slowmove (0, 25); // raise end effecotr to clear bottles over arm swing start up action Servo_5.slowmove (78, 18);//set up elbow 5 & 4 angles for grab delay(3000); Servo_1.slowmove (172, 55);// gently final grab of bottle Servo_1.wait(); // wait for servo 1 to finish Servo_3.slowmove (10, 4); // raise up bottle Servo_5.slowmove (140, 10);//set up elbow 5 & 4 angles for grab departure Servo_5.wait(); // wait for servo 5 to finish Servo_6.slowmove (75, 14); // side swing arm to get over human cup Servo_6.wait(); // wait for servo 6 to finish Servo_4.slowmove (180, 23); //straigten out elos and below too Servo_5.slowmove (5, 15); //straigten out elos and below too Servo_3.slowmove (72, 15); //straigten out elos and below too delay(2400); Servo_2.slowmove (0, 65);// twist rist to gently pour liquid gold into human cup Servo_2.wait(); // wait for servo 2 to finish delay(3000); Servo_5.slowmove (28, 3); //straigten out elos and below too Servo_5.wait(); // wait for servo to finish Servo_5.slowmove (10, 3); //straigten out elos and below too Servo_5.wait(); // wait for servo to finish Servo_2.slowmove (20, 150);// twist jitter for personification delay(100); Servo_2.slowmove (0, 150);// twist jitter for personification delay(100); Servo_2.slowmove (20, 150);// twist jitter for personification delay(300); Servo_2.slowmove (0, 150);// twist jitter for personification delay(100); Servo_2.slowmove (20, 150);// twist jitter for personification delay(100); Servo_2.slowmove (0, 150);// twist jitter for personification delay(700); Servo_3.slowmove (80, 150); //shake elbow for personifcaiton and get EVRY last drop out delay(200); Servo_3.slowmove (70,160); //shake elbow for personifcaiton and get EVRY last drop out delay(300); Servo_3.slowmove (75, 170); //shake elbow for personifcaiton and get EVRY last drop out delay(200); Servo_3.slowmove (80,180); //shake elbow for personifcaiton and get EVRY last drop out delay(300); Servo_2.slowmove (20, 150);// twist jitter for personification delay(100); Servo_2.slowmove (0, 150);// twist jitter for personification delay(300); Servo_4.slowmove (180, 10); // Servo_5.slowmove (100, 15); // delay(350); Servo_2.slowmove (180, 75);// twist rist to get bottle pointing mostly up in non drop configuration delay(750); Servo_3.slowmove (170, 15); // raise end effecotr to clear bottles over arm swing start up action; delay(500); Servo_6.slowmove (180, 25); // side swing arm to get over trash can delay(2000); Servo_3.slowmove (170, 20); // raise end effecotr to clear bottles over arm swing start up action; Servo_3.wait(); // wait for servo 3 to finish Servo_4.slowmove (100, 22); // Servo_4.wait(); // wait for servo to finish Servo_5.slowmove (90, 27); // Servo_5.wait(); // wait for servo to finish delay(500); Servo_2.slowmove (160, 22); // delay(1500); Servo_1.slowmove (100, 150);// aggressivly let go of bottle so it can fall into trash can delay(1000); //set up to staging area before next drink command Servo_1.slowmove (100, 25);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (180, 35);// twist rist to properly aling with bottle Servo_3.slowmove (180, 15); // raise end effecotr to clear bottles over arm swing start up action; Servo_4.slowmove (160, 15); // Servo_5.slowmove (180, 15); // Servo_6.slowmove (180, 15);//slowly swing arm to intemrideay stagin area } else if (a <= 1500){ //Staging positons ready to accept human command for drink via placing cup in sonar range zone Servo_1.slowmove (90, 20);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (180, 30);// twist rist to properly aling with bottle Servo_3.slowmove (100, 10); // raise end effecotr to clear bottles over arm swing start up action; Servo_4.slowmove (40, 5); // Servo_5.slowmove (180, 20); // Servo_6.slowmove (180, 10);//slowly swing arm to intemrideay stagin area Servo_7.slowmove (150, 5); //move lower bottle clamp holder out of way to allow bottle to lide into spot once released Servo_8.slowmove (330, 5); //move rocker arm out of way to letbottle slide down wihtout hitting anything once its released Servo_9.slowmove (180,10);// attmepts to put spin 360 servo in stationay mode, may need loght tweaaking Servo_10.slowmove (140, 1); //open cap pinch fingers Servo_11.slowmove (180, 30);//reset bottle bouncer for next slide down delay(600); } while ((a <= 15) && (a >=0)) { Servo_6.slowmove (80, 30);//slowly swing arm to intemrideay stagin area delay(1000); Servo_1.slowmove (170, 5);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (170, 2);// twist rist to properly aling with bottle Servo_3.slowmove (43, 7); // raise end effecotr to clear bottles over arm swing start up action; Servo_4.slowmove (95, 5); // Servo_5.slowmove (38, 5); // Servo_7.slowmove (150, 5); //move lower bottle clamp holder out of way to allow bottle to lide into spot once released Servo_8.slowmove (360, 5); //move rocker arm out of way to letbottle slide down wihtout hitting anything once its released Servo_9.slowmove (180,10);// attmepts to put spin 360 servo in stationay mode, may need loght tweaaking Servo_10.slowmove (140, 1); //open cap pinch fingers Servo_11.slowmove (180, 30);//reset bottle bouncer for next slide down; a=sr04.Distance(); Serial.print(a); Serial.println("cm"); delay(2000); } /*Servo_1.slowmove (100, 20);//slowly swing arm to intemrideay stagin area Servo_1.wait(); // wait for servo to finish unpinching Servo_2.slowmove (180, 30);// twist rist to properly aling with bottle Servo_2.wait(); // wait for servo0 to finish unpinching Servo_3.slowmove (180, 10); // raise end effecotr to clear bottles over arm swing start up action; Servo_3.wait(); // wait for servo to finish unpinching Servo_4.slowmove (160, 10); // Servo_4.wait(); // wait for servo to finish unpinching Servo_5.slowmove (180, 10); // Servo_5.wait(); // wait for servo to finish unpinching Servo_6.slowmove (180, 10);//slowly swing arm to intemrideay stagin area Servo_6.wait(); // wait for servo to finish unpinching Servo_7.slowmove (150, 5); //move lower bottle clamp holder out of way to allow bottle to lide into spot once released Servo_7.wait(); // wait for servo to finish unpinching Servo_8.slowmove (360, 5); //move rocker arm out of way to letbottle slide down wihtout hitting anything once its released Servo_8.wait(); // wait for servo to finish unpinching Servo_9.slowmove (180,10);// attmepts to put spin 360 servo in stationay mode, may need loght tweaaking Servo_9.wait(); // wait for servo to finish unpinching Servo_10.slowmove (140, 1); //open cap pinch fingers Servo_10.wait(); // wait for servo to finish unpinching Servo_11.slowmove (180, 30);//reset bottle bouncer for next slide down Servo_11.wait(); // wait for servo to finish unpinching */ /* do { a=sr04.Distance(); Serial.print(a); Serial.println("cm"); delay(1000); Servo_1.slowmove (120, 20);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (40, 30);// twist rist to properly aling with bottle Servo_3.slowmove (180, 10); // raise end effecotr to clear bottles over arm swing start up action; Servo_4.slowmove (130, 10); // Servo_5.slowmove (130, 10); // Servo_6.slowmove (73, 5);//slowly swing arm to intemrideay stagin area Servo_6.wait(); // wait for servo to finish unpinching Servo_1.slowmove (120, 20);//slowly swing arm to intemrideay stagin area Servo_2.slowmove (40, 30);// twist rist to properly aling with bottle delay(800); } while ((a <= 6) && (a >1.7)); */ }